import { Component, Input, OnInit } from '@angular/core';
import { I18nService } from '../../core/i18n/i18n.service';
import { MessageService, UserInfoService } from '../../core/service';
import { Router } from '@angular/router';

@Component({
  selector: 'wallet-nevBar',
  templateUrl: './nevBar.html',
  styleUrls: ['./nevBar.scss']
})
export class NevBarComponent implements OnInit {
  
  @Input()
  url: string;
  
  username: string;
  
  grzxBool:boolean;

  constructor(
    private msg: MessageService,
    private i18nService: I18nService,
    private userInfoService: UserInfoService,
    private router: Router
  ) {
    this.msg.getMessage().subscribe((e) => {
      this.url = e.text;
    });
    const userInfo = this.userInfoService.getUserInfo();
    if (userInfo && userInfo.loginId) {
      this.username = this.userInfoService.getUserInfo().loginId;
    } else {
      this.router.navigateByUrl('/pages/login');
    }

  }

  logout() {
    this.userInfoService.clearUserInfo();
    this.router.navigateByUrl('/pages/login');
  }

  changeLang(lang: string) {
    this.i18nService.changeLang(lang);
  }

  ngOnInit() {
    // = this.url == 
  };

  doSth() {
    console.log('test');
  }

}
